package com.zhj.algorithm.search;

/**
 * @PackageName:com.zhj.algorithm.search
 * @ClassName:LinearSearch
 * @auter: 朱慧杰
 * @date:2020/8/8 0008 10:49
 **/
public class LinearSearch {

    // 线性查找
    public int search(int target,int[] arr) {
        // 目标元素所在下标
        int index = -1;

        for (int i = 0; i < arr.length; i++) {
            if (arr[i]==target) {
                index = i;
                break;
            }
        }
        return index;
    }

}
